package com.lujieni.consumer.controller;

import com.lujieni.consumer.context.ErpUserContext;
import com.lujieni.proxy.cloud.CloudFeign;
import com.lujieni.proxy.cloud.po.StudentPO;
import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.apm.toolkit.trace.TraceContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.concurrent.TimeUnit;

@RestController
@Slf4j
public class WebController {

    @Autowired
    private CloudFeign cloudFeign;

    @GetMapping(value = "/web")
    public String web(){
        log.info("userCode:"+ ErpUserContext.getUserCode());
/*        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }*/
        return "userCode:"+ ErpUserContext.getUserCode();
        //return cloudFeign.sayHello();
    }

    @GetMapping(value = "/bye")
    public List<StudentPO> bye(){
        log.info("WebController:bye function start");
        return cloudFeign.sayBye();
    }

}
